<?php
/**
 * Created by limx.
 * Date: 2016/3/29
 * Time: 8:37
 */
namespace Home\Controller;

use Home\Common\NoAuthController;

class LoginController extends NoAuthController
{
    public function index()
    {
        $this->display();
    }

    public function login(){
        layout(false);
        $this->display();
    }

    public function pfnLogin(){
        if(IS_POST){

            $data["username"]=I("post.name");
            $data["password"]=I("post.pwd");

            $User = D("Admin");
            $res=$User->mfnLogin($data);
            if($res){
                $this->lfnAjaxSuccess();
            }
            else{
                $this->lfnAjaxFailed($User->getError());
            }
        }
        $this->lfnAjaxFailed("连接超时，请刷新后重试！");
    }

    public function logout(){
        session("UserID",null);
        session("UserName",null);
        session("AdminAuth",null);

        $this->lfnAjaxSuccess();

    }
}